<template>
  <div class="yiqing">
    <div class="top">
      <h3>查询条件</h3>
      <div class="center">
        <div class="box">
          医生姓名:
          <input type="text" />
        </div>
        <div class="box">
          医院名称:
          <input type="text" />
        </div>
        <div class="button">
          <button>重置</button>
          <button>查询</button>
        </div>
      </div>
    </div>
    <div class="center_box">
      <div class="top">
        <h3>疾病列表</h3>
        <div class="box">
          <div @click="go">+添加</div>
        </div>
      </div>

      <div class="center">
        <el-table :data="tableData" style="width: 100%">
          <el-table-column prop="jibing" label="疾病" width="200" />
          <el-table-column prop="keshi" label="科室" width="200" />
          <el-table-column prop="miaoshu" label="疾病描述" />
          <el-table-column fixed="right" label="操作" width="200">
            <template #default>
              <el-button link type="primary" size="small" @click="fun" >删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from "vue-router";
import {onMounted, ref} from '@vue/runtime-core'


//引入pinai
import {useyiqing } from '../../stores/counter'
var store = useyiqing()

//添加疾病
const router = useRouter();
var go = () => {
  router.push("/maxindex/yiqingxiangqing")
};

//渲染数据
const tableData = ref();
onMounted(() => {
  tableData.value = store.yiqing;
  console.log(store.yiqing);
  console.log(tableData.value);
})

//删除操作

var fun=()=>{
    var i = tableData.value.findIndex((item)=>{
    return item
  })
  if(i != -1){
    tableData.value.splice(i,1)
  }
}


</script>

<style lang="scss" scoped>
.yiqing {
  width: 100%;
  height: 100%;
  background-color: rgba(128, 128, 128, 0.148);
  padding-top: 20px;
  .top {
    width: 100%;
    height: 100px;
    background-color: white;
    padding: 0 20px;
    box-sizing: border-box;

    h3 {
      width: 100%;
      height: 40px;
      line-height: 40px;
    }
    .center {
      width: 100%;
      height: 60px;
      display: flex;
      align-items: center;
      .box {
        margin-right: 20px;
        input {
          width: 100px;
          height: 25px;
          border: 1px solid rgba(128, 128, 128, 0.338);
          border-radius: 5px;
          outline: none;
        }
      }
      .button {
        width: 150px;
        height: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        button {
          width: 45%;
          height: 30px;
        }
      }
    }
  }
  .center_box {
    width: 100%;
    margin-top: 20px;
    .top {
      width: 100%;
      height: 100px;
      background-color: white;
      h3 {
        width: 100%;
        height: 50px;
        line-height: 50px;
      }
      .box {
        width: 100%;
        height: 50px;
        display: flex;
        align-items: center;
        div {
          width: 60px;
          height: 30px;
          text-align: center;
          line-height: 30px;
          color: white;
          border-radius: 5px;
          background-color: blue;
        }
      }
    }
  }
}
</style>